define(["jquery"],function($){
	var quest = {};

	/**
	 * 数据处理(若不需要数据处理，可以不写)
	 */
    quest.formatData = function(obj){
        obj.rows = obj.rows ? obj.rows : 3;
        obj.height = obj.rows * 18 + "px";
		return obj;
	}

	/**
	 * tpl模板
	 */
	quest.tpl = function(){
		return 	'<script id="tpl_question_textarea" type="text/html">'+
				'	<div {{if relationId}}relationId="{{relationId}}"{{/if}} class="qaCard form-group form-group-sm col-sm-{{length}} col-md-{{length}} grid-label-{{labelLength}}">'+
				'		<label class="control-label {{align}}">{{label}}</label>'+
				'   	<div class="control-input">'+
				'			{{if status=="default"}}'+
				'				<textarea class="form-control validatebox" rows="{{rows}}" name="{{name}}" data-type="{{type}}" data-quesId="{{id}}" data-innDeCode="{{innDeCode}}" data-deCode="{{deCode}}" data-dataUnit="{{dataUnit}}" placeholder="{{placeHolder}}" data-validate="{{validate}}" data-attention="{{attention}}"></textarea>'+
				'			{{else if status=="readonly"}}'+
				'				<p class="form-control-static form-control-static-textarea validatebox" style="height:{{height}}" name="{{name}}" data-type="{{type}}" data-quesId="{{id}}" data-innDeCode="{{innDeCode}}" data-deCode="{{deCode}}" data-dataUnit="{{dataUnit}}" placeholder="{{placeHolder}}" data-validate="{{validate}}" data-attention="{{attention}}"></p>'+
				'			{{else if status=="disabled"}}'+
				'				<textarea class="form-control validatebox" rows="{{rows}}" name="{{name}}" data-type="{{type}}" data-quesId="{{id}}" data-innDeCode="{{innDeCode}}" data-deCode="{{deCode}}" data-dataUnit="{{dataUnit}}" placeholder="{{placeHolder}}" data-validate="{{validate}}" data-attention="{{attention}}" disabled></textarea>'+
				'			{{/if}}'+
				'  		</div>'+
				'	</div>'+
				'</script>';
	}

	/**
	 * 赋值
	 */
	quest.setValue = function($dom,value){
		if( value ){
			$dom.hasClass("form-control-static") ? $dom.html(value.quesValue) : $dom.val(value.quesValue);
		}
	}

	/**
	 * 获取value（保存时，获取每个dom对应的答案）
	 */
	quest.getValue = function($dom,name){
		var value = {};
		value.quesValue = $dom.hasClass("form-control-static") ? $dom.html() : $dom.val();
		value.quesId = $dom.attr("data-quesId");
		value.deCode = $dom.attr("data-deCode");
		value.innDeCode = $dom.attr("data-innDeCode");
		var dataUnit = $dom.attr("data-dataUnit");
		if( dataUnit ) value.dataUnit = dataUnit;
		return value;
	}

	return quest;
});